package com.test.group.plugin.demo.window.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.options.ShowSettingsUtil;

/**
 * @author tianfeng
 */
public class DialogAction extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        // 发起一个对话窗口

        // 获取到idea编辑界面实例
        Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
        // 获取编辑实例选择模式
        SelectionModel selectionModel = editor.getSelectionModel();
        // 获取选中文本信息
        String selectedText = selectionModel.getSelectedText();

        // 开启弹窗
        TestDialog testDialog = new TestDialog();

        // 配置显示信息
        testDialog.setContext(selectedText);

        // 显示弹窗
        testDialog.show();
    }


}
